package fun.formoji.alg.api.fallback;


import feign.hystrix.FallbackFactory;
import fun.formoji.alg.api.TrackingDataApi;
import fun.formoji.alg.resp.UserEventVO;
import fun.formoji.commons.model.RestResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <code>TrackingDataApiFallBack</code>
 * <desc>
 * 描述：
 * <desc/>
 * <b>Creation Time:</b> 2021/4/19 11:21.
 *
 * @author hshe
 */
@Component
@Slf4j
public class TrackingDataApiFallBackFactory implements FallbackFactory<TrackingDataApi> {


    @Override
    public TrackingDataApi create(Throwable cause) {
        log.error("Failed to call {},reason:{}", TrackingDataApi.class.getName(),cause.getMessage(), cause);
        return new TrackingDataApi() {
            @Override
            public RestResponse<UserEventVO> userEvent(String userId, String event) {
                return RestResponse.fallback();
            }
        };
    }
}
